$("#getCode").on("click",function(e)
{
    //注册
    var mobile = $('#mobile').val();
    if (mobile == '') {
        layer.alert('手机号不能为空');
        return false;
    }

    send(mobile, this);
});

function send(mobile, obj)
{
    $.post(
        api_url+'/member/code/create',
        {'mobile':mobile, 'type':2},
        function (res) {
            if (res.code == 200) {
                setTime(obj);
            }
            //layer.alert(res.msg);
            return false;
        },'json'
    );
}

var countdown = 60;
function setTime(obj) {
    if (countdown == 0) {
        obj.removeAttribute("disabled");
        obj.value="获取验证码";
        countdown = 60;
        return;
    } else {
        obj.setAttribute("disabled", true);
        obj.value=countdown+"s后再发送";
        countdown--;
    }
    setTimeout(function() {
            setTime(obj) }
        ,1000)
}


$('#forget-login').click(function(){
    var mobile = $('#mobile').val();
    var code = $('#code').val();
    var password = $('#password').val();
    //var password2 = $('#password2').val();

    if (mobile == '') {
        layer.alert('手机号不能为空');
        return false;
    }

    if (code == '') {
        layer.alert('验证码不能为空');
        return false;
    }

    if (password == '') {
        layer.alert('密码不能为空');
        return false;
    }

    $.post(
        web_url+'/member/sign/forgetopt.html',
        {'mobile':mobile, 'password':password, 'code':code},
        function (msg) {
            if (msg.code == 200) location.href=web_url+'/member/default.html';
            else {
                layer.alert(msg.msg);
            }
        },'json'
    );
});